<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, branchApplyFor-scalable=no"/>
    <title>${siteName!""}|网点申请管理-${title!""}</title>
<#include "../common/header.ftl"/>
    <style>
        td {
            vertical-align: middle;
        }
    </style>
</head>
<#setting datetime_format="yyyy-MM-dd"/>
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">

            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <a href="/system/index">${siteName!""}</a>
            </div>
            <div class="lyear-layout-sidebar-scroll">
        <#include "../common/left-menu.ftl"/>
            </div>

        </aside>
        <!--End 左侧导航-->
    
    <#include "../common/header-menu.ftl"/>

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-toolbar clearfix">
                                <form class="pull-right search-bar" method="get" action="list" role="form">
                                    <div class="input-group">
                                        <div class="input-group-btn">
                                            <button class="btn btn-default dropdown-toggle" id="search-btn"
                                                    data-toggle="dropdown" type="button" aria-haspopup="true"
                                                    aria-expanded="false">
                                                网点名 <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu">
                                                <li><a tabindex="-1" href="javascript:void(0)"
                                                       data-field="title">网点名</a></li>
                                            </ul>
                                        </div>
                                        <input type="text" class="form-control" value="${branchName!""}"
                                               name="branchName"
                                               placeholder="请输入网点名">
                                        <span class="input-group-btn">
                                            <button class="btn btn-primary" type="submit">搜索</button>
                                        </span>
                                    </div>
                                </form>
                            <#include "../common/third-menu.ftl"/>
                            </div>
                            <div class="card-body">

                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                        <tr>
                                            <th>姓名</th>
                                            <th>网点名</th>
                                            <th>手机号</th>
                                            <th>网点类型</th>
                                            <th>省市区</th>
                                            <th>办公地址</th>
                                            <th>身份证号</th>
                                            <th>申请时间</th>
                                            <th>申请状态</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <#if pageBean.content?size gt 0>
                                            <#list pageBean.content as branchApplyFor>
                                            <tr>
                                                <td style="vertical-align:middle;">${branchApplyFor.adminName}</td>
                                                <td style="vertical-align:middle;">${branchApplyFor.branchName}</td>
                                                <td style="vertical-align:middle;">${branchApplyFor.mobile}</td>
                                                <td style="vertical-align:middle;">${branchApplyFor.getBranchType().getName()}</td>
                                                <td style="vertical-align:middle;">${branchApplyFor.address}</td>
                                                <td style="vertical-align:middle;">${branchApplyFor.officeAddress}</td>
                                                <td style="vertical-align:middle;">${branchApplyFor.idCard}</td>
                                                <td style="vertical-align:middle;">
                                                    <font class="text-success">${branchApplyFor.createTime}</font>
                                                </td>
                                                <td style="vertical-align:middle;">
                                                    <font class="text-success">${branchApplyFor.getBranchApplyForStatus().getName()}</font>
                                                </td>
                                                <td style="vertical-align:middle;width: 220px">
                                                    <button class="btn btn-label btn-primary"
                                                            onclick="agree(${branchApplyFor.id})"
                                                    <#if branchApplyFor.getBranchApplyForStatus().getCode() != 1>disabled</#if>>
                                                        <label>
                                                            <i class="mdi mdi-checkbox-marked-circle-outline"></i>
                                                        </label> 通过
                                                    </button>
                                                    <button class="btn btn-label btn-danger"
                                                            onclick="rejected(${branchApplyFor.id})"
                                                     <#if branchApplyFor.getBranchApplyForStatus().getCode() != 1>disabled</#if> >
                                                        <label>
                                                            <i class="mdi mdi-close"></i>
                                                        </label> 驳回
                                                    </button>
                                                </td>
                                            </tr>
                                            </#list>
                                        <#else>
                                        <tr align="center">
                                            <td colspan="9">这里空空如也！</td>
                                        </tr>
                                        </#if>
                                        </tbody>
                                    </table>
                                </div>
                            <#if pageBean.total gt 0>
                                <ul class="pagination ">
                                    <#if pageBean.currentPage == 1>
                                        <li class="disabled"><span>«</span></li>
                                    <#else>
                                        <li><a href="list?branchName=${branchName!""}&currentPage=1">«</a></li>
                                    </#if>
                                    <#list pageBean.currentShowPage as showPage>
                                        <#if pageBean.currentPage == showPage>
                                            <li class="active"><span>${showPage}</span></li>
                                        <#else>
                                            <li>
                                                <a href="list?branchName=${branchName!""}&currentPage=${showPage}">${showPage}</a>
                                            </li>
                                        </#if>
                                    </#list>
                                    <#if pageBean.currentPage == pageBean.totalPage>
                                        <li class="disabled"><span>»</span></li>
                                    <#else>
                                        <li>
                                            <a href="list?branchName=${branchName!""}&currentPage=${pageBean.totalPage}">»</a>
                                        </li>
                                    </#if>
                                    <li><span>共${pageBean.totalPage}页,${pageBean.total}条数据</span></li>
                                </ul>
                            </#if>
                            </div>
                        </div>
                    </div>

                </div>

            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<#--驳回申请模态框-->
<div class="modal fade" id="rejectedModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="exampleModalLabel">驳回申请</h4>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    驳回原因:<input class="form-control" placeholder="请输入驳回原因" id="rejectReason"/>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" id="rejectedBtn" class="btn btn-primary">提交</button>
            </div>
        </div>
    </div>
</div>
<#include "../common/footer.ftl"/>
<script type="text/javascript" src="/admin/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/admin/js/main.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {

    });


    //通过申请
    function agree(id) {
        $.ajax({
            url: "/admin/branchApplyFor/agree",
            type: "POST",
            data: {id: id},
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                    showSuccessMsg('通过成功!', function () {
                        window.location.reload()
                    })
                } else {
                    showErrorMsg(data.msg);
                }
            },
            error: function (data) {
                alert('网络错误!');
            }
        });
    }

    //驳回申请

    function rejected(id) {
        $("#rejectedModal").modal("show");
        $("#rejectedBtn").attr("data-key", id);
    }

    $("#rejectedBtn").click(function () {
        var id = $(this).attr("data-key");
        var rejectReason = $("#rejectReason").val();
        if (rejectReason == "") {
            showErrorMsg("驳回原因不能为空");
        }
        $.ajax({
            url: "/admin/branchApplyFor/rejected",
            type: "POST",
            data: {
                id: id,
                rejectReason: rejectReason
            },
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                    showSuccessMsg('驳回成功!', function () {
                        window.location.reload();
                    })
                } else {
                    showErrorMsg(data.msg);
                }
            },
            error: function (data) {
                alert('网络错误!');
            }
        });
    });


</script>
</body>
</html>